<?php

$personProperties = array(
    'http://lod2.eu/schema/nameAffix', 
    'http://lod2.eu/schema/partner'
);

$templateData = array(
    'title'             => $this->title,
    'resourceUri'       => $this->resourceUri,
    'description'       => $this->description,
    'descriptionHelper' => $this->descriptionHelper,
    'options'           => $this->options
);
?>

<div class="maincontent">
    <div class="section">
        <h3><?php echo $this->description['http://xmlns.com/foaf/0.1/name'][0]['value'] ?></h3>
        <?php if (isset($this->description['http://xmlns.com/foaf/0.1/depiction'][0]['value'])): ?>
        <img rel="foaf:depiction" 
             src="<?php echo $this->description['http://xmlns.com/foaf/0.1/depiction'][0]['value'] ?>" 
             alt="depiction of <?php echo $this->title ?>"/>
        <?php endif; ?>
        <div><?php echo $this->title ?></div>
        <?php foreach ($personProperties as $property): ?>
        <?php if (isset($this->description[$property][0]['value'])): ?>
        <?php if ($this->description[$property][0]['type'] == 'literal'): ?>
            <div><?php echo $this->description[$property][0]['value'] ?></div>
        <?php else: ?>
            <div><?php echo $this->descriptionHelper->getTitle($this->description[$property][0]['value']) ?></div>
        <?php endif; ?>
        <?php endif; ?>
        <?php endforeach; ?>
    </div>
</div>

<?php

function person_title($description)
{
    if (isset($description['http://purl.org/dc/terms/creator'][0]['value'])) {
        $creator = $description['http://purl.org/dc/terms/creator'][0]['value'];
        $creatorInstance = new OntoWiki_Resource($creator, OntoWiki::getInstance()->selectedModel);
        $creatorDescription = $creatorInstance->getDescription();
        $creatorDescription = $creatorDescription[$creator];
        $creatorHelper = $creatorInstance->getDescriptionHelper();

        $title = $creatorInstance->getTitle();
        $affixes = array();
        if (isset($creatorDescription['http://lod2.eu/schema/partner'][0]['value'])) {
            $partner = $creatorDescription['http://lod2.eu/schema/partner'][0]['value'];
            $affixes[] = $creatorHelper->getTitle($partner);
        }

        if (isset($creatorDescription['http://xmlns.com/foaf/0.1/title'][0]['value'])) {
            $title = sprintf(
                '%s %s', 
                $creatorDescription['http://xmlns.com/foaf/0.1/title'][0]['value'], 
                $title);
        }

        if (isset($creatorDescription['http://lod2.eu/schema/nameAffix'][0]['value'])) {
            $affixes[] = $creatorDescription['http://lod2.eu/schema/nameAffix'][0]['value'];;
        }

        if (count($affixes) > 0) {
            $title .= sprintf(' (%s)', implode(', ', $affixes));
        }
    }
}

?>